package com.generation.tool.controller;

import com.generation.tool.pojo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.generation.tool.pojo.po.TbAdmin;
import com.generation.tool.service.ITbAdminService;

/**
 * @Author: 吃我一钊
 * @Description: 管理信息表控制层
 * @Date: 2025/01/27
 */
@RestController
@RequestMapping("/tbAdmin")
public class TbAdminController {

	@Autowired
	private ITbAdminService tbAdminService;

	/**
	 * 新增数据
	 * @param tbAdmin
	 * @return
	 */
	@PostMapping("/save")
	public R<Void> save(@RequestBody TbAdmin tbAdmin) {
		tbAdminService.save(tbAdmin);
		return R.ok();
	}

	/**
	 * 根据id删除
	 * @param tbAdminId
	 * @return
	 */
	@DeleteMapping("/deleteById/{tbAdminId}")
	public R<Void> deleteById(@PathVariable("tbAdminId") Integer tbAdminId) {
		tbAdminService.removeById(tbAdminId);
		return R.ok();
	}

	/**
	 * 根据id修改数据
	 * @param tbAdmin
	 * @return
	 */
	@PutMapping("/updateById")
	public R<Void> updateById(@RequestBody TbAdmin tbAdmin) {
		tbAdminService.updateById(tbAdmin);
		return R.ok();
	}

	/**
	 * 根据id查询数据
	 * @param tbAdminId
	 * @return
	 */
	@GetMapping("/getById/{tbAdminId}")
	public R<TbAdmin> getById(@PathVariable("tbAdminId") Integer tbAdminId) {
		TbAdmin tbAdmin = tbAdminService.getById(tbAdminId);
		return R.ok(tbAdmin);
	}
	/**
	 * 查询所有数据
	 * @return
	 */
	@GetMapping("/list")
	public R<List<TbAdmin>> list() {
		List<TbAdmin> tbAdminList = tbAdminService.list();
		return R.ok(tbAdminList);
	}

}